﻿@using KL.Store.Core
@{
    Layout = "~/Views/Shared/" + Parameters.Layout + ".cshtml";
    var cssClass = "col-xs-12 col-sm-12 col-md-3 col-lg-2 left first last";
    var suggestedClass = "col-xs-12 col-sm-12 col-md-12 col-lg-12 right";
    if (Parameters.Theme == "DK" || Parameters.Theme == "EO")
    {
        cssClass = "col-xs-12 col-sm-12 col-md-3 col-lg-3 left first last";
    }
    else if (Parameters.Theme == "WU")
    {
        cssClass = "col-xs-12 col-sm-12 col-md-4 col-lg-3 left";
        suggestedClass = "col-xs-12 col-sm-12 col-md-8 col-lg-9 right";
    }
}
<div class="@cssClass">
    @{ Html.RenderAction("Categories", "Partials"); }
    <form name="product-filter" method="get">
        @{Html.RenderAction("GetBrandsSelection", "Products", new { id = 0 });}
        <div class="product-filter">
            <div class="product-filter-inner">
                <h5 class="product-filter-title">Fiyat Aralığı  @if (!Parameters.ShowPriceRangeAsCheckbox)
                                                                {<text>(TL)</text>}</h5>
                <div class="product-filter-options">
                    <ul class="price-range-inputs" @{ if (Parameters.ShowPriceRangeAsCheckbox)
                                                      {<text>style="display:none;"</text>} }>
                        <li>
                            <input type="text" name="enAzUcret" id="enAzUcret" class="form-control" disabled="disabled" />
                        </li>
                        <li class="price-range-and">ve</li>
                        <li>
                            <input type="text" name="enFazlaucret" id="enFazlaucret" class="form-control" disabled="disabled" />
                        </li>
                    </ul>
                    @if (Parameters.ShowPriceRangeAsCheckbox)
                    {
                        <ul class="price-range-check">
                        </ul>
                    }
                    <div class="clearfix"></div>
                    @if (!Parameters.ShowPriceRangeAsCheckbox)
                    {
                        <div id="price-range"></div>
                    }
                </div>
                <div class="clearfix"></div>
            </div>
        </div>
    </form>
</div>
<div class="contentBestSellerPage">
    @{
        Html.RenderAction("GetNewProductsPage", "Products", new { id = 0, brand = 0, sort = 2, order = 1, itemCount = Parameters.MaxProductCountForPage, totalItemCount = Parameters.MaxProductCountForBestSellerPage });
    }
</div>
<div class="@(suggestedClass)">
    @{Html.RenderAction("OurSuggestions", "Partials");}
</div>
<script>
    var minPriceDefault = parseInt($('#minPriceDefault').val()) - 1;
    var maxPriceDefault = parseInt($('#maxPriceDefault').val()) + 1;
</script>
@if (Parameters.ShowPriceRangeAsCheckbox)
{
    <script>
        //var aralikKatsayi = 2;
        //var aralikArtisi = 150;
        //var guncelBaslangic = minPriceDefault;
        //var guncelAralik = 0;
        //while (guncelAralik <= maxPriceDefault) {

        //}
        $(function ()
        {
            if (minPriceDefault < 50)
            {
                $(".price-range-check").append("<li><input class=\"product-range-input-check\" type=\"checkbox\" id=\"aralik050\" data-min=\"0\" data-max=\"50\" /><label for=\"aralik050\">0 TL - 50 TL</label></li>");
            }
            if (maxPriceDefault >= 50 && minPriceDefault <= 100)
            {
                $(".price-range-check").append("<li><input class=\"product-range-input-check\" type=\"checkbox\" id=\"aralik50100\" data-min=\"50\" data-max=\"100\" /><label for=\"aralik50100\">50 TL - 100 TL</label></li>");
            }
            if (maxPriceDefault >= 100 && minPriceDefault <= 250)
            {
                $(".price-range-check").append("<li><input class=\"product-range-input-check\" type=\"checkbox\" id=\"aralik100250\" data-min=\"100\" data-max=\"250\" /><label for=\"aralik100250\">100 TL - 250 TL</label></li>");
            }
            if (maxPriceDefault >= 250 && minPriceDefault <= 500)
            {
                $(".price-range-check").append("<li><input class=\"product-range-input-check\" type=\"checkbox\" id=\"aralik250500\" data-min=\"250\" data-max=\"500\" /><label for=\"aralik250500\">250 TL - 500 TL</label></li>");
            }
            if (maxPriceDefault >= 500 && minPriceDefault <= 750)
            {
                $(".price-range-check").append("<li><input class=\"product-range-input-check\" type=\"checkbox\" id=\"aralik500750\" data-min=\"500\" data-max=\"750\" /><label for=\"aralik500750\">500 TL - 750 TL</label></li>");
            }
            if (maxPriceDefault >= 750 && minPriceDefault <= 1000)
            {
                $(".price-range-check").append("<li><input class=\"product-range-input-check\" type=\"checkbox\" id=\"aralik7501000\" data-min=\"750\" data-max=\"1000\" /><label for=\"aralik7501000\">750 TL - 1000 TL</label></li>");
            }
            if (maxPriceDefault >= 1000 && minPriceDefault <= 1500)
            {
                $(".price-range-check").append("<li><input class=\"product-range-input-check\" type=\"checkbox\" id=\"aralik10001500\" data-min=\"1000\" data-max=\"1500\" /><label for=\"aralik10001500\">1000 TL - 1500 TL</label></li>");
            }
            if (maxPriceDefault >= 1500 && minPriceDefault <= 2500)
            {
                $(".price-range-check").append("<li><input class=\"product-range-input-check\" type=\"checkbox\" id=\"aralik15002500\" data-min=\"1500\" data-max=\"2500\" /><label for=\"aralik15002500\">1500 TL - 2500 TL</label></li>");
            }
            if (maxPriceDefault >= 2500 && minPriceDefault <= 5000)
            {
                $(".price-range-check").append("<li><input class=\"product-range-input-check\" type=\"checkbox\" id=\"aralik25005000\" data-min=\"2500\" data-max=\"5000\" /><label for=\"aralik25005000\">2500 TL - 5000 TL</label></li>");
            }
            if (maxPriceDefault >= 5000 && minPriceDefault <= 10000)
            {
                $(".price-range-check").append("<li><input class=\"product-range-input-check\" type=\"checkbox\" id=\"aralik500010000\" data-min=\"5000\" data-max=\"10000\" /><label for=\"aralik500010000\">5000 TL - 10000 TL</label></li>");
            }
            if (maxPriceDefault >= 10000)
            {
                $(".price-range-check").append("<li><input type=\"checkbox\" id=\"aralik1000plus\" data-min=\"10000\" data-max=\"9999999999\" /><label for=\"aralik1000plus\">10000'den Fazla</label></li>");
            }

            $(".product-range-input-check").change(function ()
            {
                var checkedInputId = $(this).attr("id");
                var checkedFound = false;
                $(".product-range-input-check").each(function ()
                {
                    if ($(this).attr("id") != checkedInputId)
                    {
                        $(this).attr("checked", false);
                    }
                    if ($(this).attr("checked"))
                    {
                        checkedFound = true;
                    }
                });
                if (checkedFound)
                {
                    $("#enAzUcret").val($(this).attr("data-min"));
                    $("#enFazlaucret").val($(this).attr("data-max"));
                }
                else
                {
                    $("#enAzUcret").val(0);
                    $("#enFazlaucret").val(99999999999);
                }
                SortMinMaxPrice();
            });
        });

        $(document).ready(function ()
        {
            $(".product-filter-options").customScrollbar();
            $(".product-filter-options .scroll-bar .thumb").html("<div class=\"thumb-image\"></div>");
        });

    </script>
}
else
{
    <script>
        $("#price-range").slider({
            range: true,
            min: minPriceDefault,
            max: maxPriceDefault,
            values: [minPriceDefault, maxPriceDefault],
            slide: function (event, ui)
            {
                $("#enAzUcret").val(ui.values[0]);
                $("#enFazlaucret").val(ui.values[1]);
            },
            change: function (event, ui)
            {
                SortMinMaxPrice();
            }
        });
        $("#enAzUcret").val($("#price-range").slider("values", 0));
        $("#enFazlaucret").val($("#price-range").slider("values", 1));
    </script>
}
<script>
    $('a.addToCart').click(function ()
    {
        var qsId = $(this).attr('id').split("_")[1];
        $('#cart').load('/Cart/Insert', { id: qsId });
        $('#sepetMinimalContent').load('/Cart/GetMinimal', { showPhotos: true, ShowAcrIcrLinks: true });
        $('body,html').animate({
            scrollTop: 0
        }, 800);
        $(".sepetFull img").delay(1000).fadeOut("slow").fadeIn("slow");
        return false;
    });
</script>
